var jQ = jQuery.noConflict();
var $ = jQuery.noConflict();
jQ(document).ready(function(){
	function get_report_day(){
		if(jQ("#id_date_year").val() !="" && jQ("#id_date_month").val() != "" && jQ("#id_date_day").val() != ""){
			jQ.ajax({
				url: "/washing/show_report_day/",
				type: "POST",
				data: jQ("#id_report_form").serialize(), 
				async: false,
				success: function (data){
					var result = JSON.parse(data);
					if (result.status == "ok"){
						location.href = "/this_site/dayreport/" + result.pk;
					}
				}
			});
		}
		return false;
	}
	
	jQ("#id_send_report_form").live("click", function(){ return get_report_day(); });
	jQ("#id_send_report_start_end_form").live("click", function(){
		var year = jQ("#id_date_start_year").val();
		var month = jQ("#id_date_start_month").val();
		var day = jQ("#id_date_start_day").val();
		
		var year_end = jQ("#id_date_end_year").val();
		var month_end = jQ("#id_date_end_month").val();
		var day_end = jQ("#id_date_end_day").val();
		
		jQ("#id_report_start_end_form").attr("action", "/washing/get_report_day/"+year+"-"+month+"-"+day+"_to_"+year_end+"-"+month_end+"-"+day_end+".xls");
		location.href = "/washing/get_report_day/"+year+"-"+month+"-"+day+"_to_"+year_end+"-"+month_end+"-"+day_end+".xls";
		return false;
	});
});